package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.WeiXinService;
import com.yixun.qfbao.apidto.ChangeWeixinModelSettingReqDto;
import com.yixun.qfbao.apidto.ChangeWeixinModelSettingResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.ChangeWeixinModelSettingReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("changeWeixinModelSettingHander")
public class ChangeWeixinModelSettingHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(ChangeWeixinModelSettingHander.class);

    @Autowired
    private WeiXinService weiXinService;
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        ChangeWeixinModelSettingReqVo req = (ChangeWeixinModelSettingReqVo)reqDto;
        ChangeWeixinModelSettingReqDto reqDto1 = req.getParams();
        BaseResponseDTO<ChangeWeixinModelSettingResDto> res = new BaseResponseDTO<>();
        ChangeWeixinModelSettingResDto resDto = new ChangeWeixinModelSettingResDto();
        try{
            resDto = weiXinService.changeWexinModelSetting(reqDto1);
            res.setResult(resDto.getResult());
        }catch (Exception e){
            logger.error("changeWeixinModelSettingHander error:{}", e);
            res.setResult(ResultEnum.FAIL.getNo());
            res.setErrorMsg("设置短信模板开关失败");
        }
        return res;
    }
}
